# -*- coding:utf-8 -*-
# @Time: 2020/7/18 11:17
# @Author: liupengfei
# @File: permission.py

from rest_framework import permissions


class IsMemberUser(permissions.BasePermission):
    def has_permission(self, request, view):
        if not request.user or not request.user.is_authenticated:
            return False
        return request.user.is_member()


class IsMemberOrAdminUser(permissions.BasePermission):
    def has_permission(self, request, view):
        if not request.user or not request.user.is_authenticated:
            return False
        return bool(request.user.is_member() or request.user.is_administrator())
